
import React, { Component } from 'react';
import {View} from 'react-native'
import  StudentStaticItem from './student_static_item'
import Loading from '../common/loading_common'
import {GetStudentReports} from '../../config/api'
import styles,{BLUE} from '../../config/styles'

class StudentStaticIndex extends Component {
    state = {
        studentStatics: [],
        loading: true
    }

    componentDidMount () {
        GetStudentReports().then((data)=>{
            if(data.code == 0){
                this.setState({
                    studentStatics:data.data,
                    loading: false
                })
            }
        });
    }

    render () {
        const {studentStatics, loading } = this.state
        if (loading == true) {
            return <Loading />
        } else {
            return (
                <View tabLabel='学生统计' style={[styles.main_body]}>
                    <View style={{marginTop:15,paddingLeft:10,paddingRight:10,backgroundColor:'#fff'}}>
        
                        {
                            studentStatics.map((studentStatic,index)=>{
                                return <StudentStaticItem studentStatic = {studentStatic} key={index}/>
                            })
                        }
        
                    </View>
                </View>
            )
        }
      
    }
}

export default StudentStaticIndex

